/**
 * Description:
 * Class Name:InstanceofTest
 * Date:2022/1/12 14:32
 *
 * @author LTisme
 * @version JAVA17
 */
package 疯狂Java讲义.第5章_面向对象_上.多态.第5_7.引用变量的强制类型转换;

public class InstanceofTest {
    public static void main(String[] args) {
        Object hello = "hello";
        System.out.println("字符串是否是Object类的实例："+(hello instanceof Object));
        System.out.println("字符串是否是String类的实例："+(hello instanceof String));
        System.out.println("字符串是否是Math类的实例："+(hello instanceof Math));
        System.out.println("字符串是否是Comparable类的实例："+(hello instanceof Comparable<?>));

        var a = "Hello";
        // 下面的String类与Math类没有继承关系，所以下面代码编译无法通过
        // System.out.println("字符串是否是Object类的实例："+(a instanceof Math));
    }
}
